import request from '@/utils/request';
import axios from 'axios';

/**
 * 获取所有蜂农位置信息
 * @param params 可选搜索参数
 */
export const getBeekeeperLocations = (params) => {
  return request.get('/location/beekeeper', { params });
};

/**
 * 获取所有接管区域信息
 */
export const getManagedAreas = () => {
  return request.get('/location/areas');
};

/**
 * 订阅位置更新（用于WebSocket长连接）
 */
export const subscribeLocationUpdates = (callback) => {
  // 实际项目中使用WebSocket实现实时推送
  const ws = new WebSocket(`ws://${window.location.host}/ws/location`);
  ws.onmessage = (event) => {
    const data = JSON.parse(event.data);
    callback(data);
  };
  return ws;
};